home *** CD-ROM | disk | FTP | other *** search
- Path: ts5-024.jaxnet.com!user
- From: garyg@jax.jaxnet.com (Gary M. Greenberg)
- Newsgroups: comp.lang.c
- Subject: Re: Is this ok: *pointer++ = value ??
- Date: Sat, 06 Jan 1996 22:11:53 -0500
- Organization: Southeast Network Services, Inc.
- Message-ID: <garyg-0601962211530001@ts5-024.jaxnet.com>
- References: <4cklvv$nmm@alcor.usc.edu> <4cm710$ni1@nntpd2.cxo.dec.com>
- NNTP-Posting-Host: ts5-024.jaxnet.com
-
- In article <4cm710$ni1@nntpd2.cxo.dec.com>, Brian Hibbert
- <b_hibbert@csc32.enet.dec.com> wrote:
-
- [snip]
- > > int i,p;
- > >
- > > for (i=0; i<50; i++) p++ = i;
- > >
- > This is undefined because it is no clear what the compiler is supposed to
- > do. Do you increment the value of "p" first then assign the value of
- > "i" to "p". Or do you assign the value of "i" to "p" then increment
- > "p"? How you answer that question determines wether "p" ends up with the
- > value of "i" or "i+1". Exactly what happens on your compiler is
- > undefined and therefor the compiler could do it either way, could flag it
- > as an error, or could decide to put any value it wants in "i" and "p".
-
- Undefined??! It's illegal.
- It shouldn't compile because you cannot assign a value
- to something which is _not_ an object; that is, "p" is not an lvalue.
- Or, have I missed something?
-
- Pointer <pun intended> for Abu <originator of this thread> && Brian ;-) :
- grab a copy of Ted Jensen's "A Tutorial on Pointers And Arrays in C"
- available as
- ftp://oak.oakland.edu/simtel/msdos/c/ptrtut01.zip
-
- > Brian Hibbert
-
- C'ya,
-
- gary /* the Sorcerer's Apprentice */
-
- "Why do we have to hide from the police, Daddy?" | Truth:
- "Because we use vi, honey. They use emacs." | This .sig is pirated
-